home *** CD-ROM | disk | FTP | other *** search
/ Network Supervisor's Toolkit / Network Supervisor's Toolkit.iso / tools / nwtp06 / chkatt.pas < prev    next >
Pascal/Delphi Source File  |  1996-07-10  |  1KB  |  44 lines

  1. {X+,V-,B-}
  2.  
  3. program ChkAtt;
  4.  
  5. { Example for the nwConn unit/ NwTP 0.6 API. (c) 1993,1995, R. Spronk }
  6.  
  7. uses nwMisc,nwBindry,nwConn;
  8.  
  9. Var srvr,usr:string;
  10.     connId,PrConnId:Byte;
  11.     MyObjName:string;
  12.     MyObjType:word;
  13.     MyObjId:Longint;
  14.     accLev:byte;
  15.  
  16. begin
  17. if ParamCount<>2
  18.  then begin
  19.       writeln('CHKATT - Batch file utility to check for an attachment.');
  20.       writeln;
  21.       writeln('Supply 2 parameters   : CHKATT <servername> <username>');
  22.       writeln('If attached/logged on : ChkAtt returns errorlevel 0');
  23.       writeln('in *all* other circumstances, errorlevel 1 will be returned.');
  24.       halt(1);
  25.       end;
  26. srvr:=ParamStr(1);UpString(srvr);
  27. Usr:=paramStr(2);UpString(usr);
  28. IF NOT GetConnectionId(srvr,connId)
  29.  then halt(1);
  30. { ok.. attachment to <servername> exists... am I logged in as <username> ? }
  31. GetPreferredConnectionId(prConnId);
  32. SetPreferredConnectionId(connId);
  33. IF GetBinderyAccessLevel(accLev,MyObjId)
  34.  and GetBinderyObjectName(MyObjId,MyObjName,MyObjType)
  35.  and (MyObjName=usr)
  36.  then begin
  37.       SetPreferredConnectionId(PrConnId);
  38.       halt(0);
  39.       end
  40.  else begin
  41.       SetPreferredConnectionId(PrConnId);
  42.       halt(1);
  43.       end
  44. end.